//package com.zy.experience_system.exception;
//
//import com.zy.experience_system.util.ResultUtil;
//import com.zy.experience_system.util.ResultVOUtil;
//import com.zy.experience_system.vo.ResultVO;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.shiro.ShiroException;
//import org.springframework.http.HttpStatus;
//import org.springframework.validation.BindingResult;
//import org.springframework.validation.ObjectError;
//import org.springframework.web.bind.MethodArgumentNotValidException;
//import org.springframework.web.bind.annotation.ExceptionHandler;
//import org.springframework.web.bind.annotation.ResponseStatus;
//import org.springframework.web.bind.annotation.RestControllerAdvice;
//
//@Slf4j
//@RestControllerAdvice
//public class GlobalExceptionHandler {
//
//    @ResponseStatus(HttpStatus.UNAUTHORIZED)
//    @ExceptionHandler(value = ShiroException.class)
//    public ResultVO handler(ShiroException e) {
//        log.error("运行时异常：----------------{}", e);
//        return ResultVOUtil.error(401, e.getMessage());
//    }
//
//    @ResponseStatus(HttpStatus.BAD_REQUEST)
//    @ExceptionHandler(value = MethodArgumentNotValidException.class)
//    public ResultVO handler(MethodArgumentNotValidException e) {
//        log.error("实体校验异常：----------------{}", e);
//        BindingResult bindingResult = e.getBindingResult();
//        ObjectError objectError = bindingResult.getAllErrors().stream().findFirst().get();
//
//        return ResultVOUtil.error(objectError.getDefaultMessage());
//    }
//
//    @ResponseStatus(HttpStatus.BAD_REQUEST)
//    @ExceptionHandler(value = IllegalArgumentException.class)
//    public ResultVO handler(IllegalArgumentException e) {
//        log.error("Assert异常：----------------{}", e);
//        return ResultVOUtil.error(e.getMessage());
//    }
//
//    @ResponseStatus(HttpStatus.BAD_REQUEST)
//    @ExceptionHandler(value = RuntimeException.class)
//    public ResultVO handler(RuntimeException e) {
//        log.error("运行时异常：----------------{}", e);
//        return ResultVOUtil.error(e.getMessage());
//    }
//
//}
